package com.hdit.guimei.web;

import com.hdit.guimei.domain.GoodsOrder;
import com.hdit.guimei.domain.Order_item;
import com.hdit.guimei.service.OrderItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @基本功能:
 * @ClassName: OrderItemController
 * @Description: TODO
 * @Author: 李嘉明
 * @Date: 2021/1/19 10:44
 * @Version 1.0
 */
@Controller
//@RequestMapping(value = "/user")
public class OrderItemController {
    @Autowired
    private OrderItemService orderItemService;

    /**
     * @Method: findAllOrders
     * @函数(方法)功能: 查询所有订单详细信息
     * @Author: 李嘉明
     * @params: []
     * @Return: java.util.List<com.hdit.guimei.domain.Order_item>
     * @Exception:
     * @Date: 2021/1/19 10:49
     */
    @RequestMapping("/findAllOrders")
    @ResponseBody
    List<Order_item> findAllOrders() {
        List<Order_item> order_items = orderItemService.findAllOrders();
        return order_items;
    }

    /**
     * @Method: updateOrderItemState
     * @函数(方法)功能: 修改展示订单页面状态
     * @Author: 李嘉明
     * @params: [order_item_id, order_state]
     * @Return: int
     * @Exception:
     * @Date: 2021/1/19 11:39
     */
    @RequestMapping("/updateOrderItemState")
    @ResponseBody
    int updateOrderItemState(String order_item_id, int order_state) {
        Map map = new HashMap();
        map.put("order_item_id", order_item_id);
        map.put("new_state", order_state);
        System.out.println(map);
        return orderItemService.updateOrderItemState(map);
    }

    /**
    * @Method: addOrderItem
    * @函数(方法)功能: 添加订单信息
    * @Author: 李嘉明
    * @params:  [order_item]
    * @Return: int
    * @Exception:
    * @Date: 2021/1/19 14:19
    */
    @RequestMapping("/addOrderItem")
    @ResponseBody
    int addOrderItem(Order_item order_item) {
        order_item.setTotal_price(order_item.getOriginal_price() * order_item.getCount());
        return orderItemService.addOrderItem(order_item);
    }
    /***
    * @Method 用户查看自己评论
    * @Author 冰镇小可乐
    * @params  [id, order_state]
    * @Return java.util.List<com.hdit.guimei.domain.GoodsOrder>
    * @Exception  
    * @Date 2021/1/22 8:40
    */
    @RequestMapping("/findGoodsOrderFront")
    List<GoodsOrder> findGoodsOrderFront(int id,int order_state){
        List<GoodsOrder> list =orderItemService.findGoodsOrderFront(id,order_state);
        return null;
    }
    /***
    * @Method  后台订单管理
    * @Author 冰镇小可乐
    * @params  [order_state]
    * @Return java.util.List<com.hdit.guimei.domain.GoodsOrder>
    * @Exception  
    * @Date 2021/1/22 8:40
    */
    @RequestMapping("/findGoodsOrderBehind")
    List<GoodsOrder> findGoodsOrderBehind(int order_state){
        List<GoodsOrder> list =orderItemService.findGoodsOrderBehind(order_state);
        return list;
    }
}
